﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PublicClass;
using S.Produce.Api.Application.Commands.ShiftCommands;

namespace S.Produce.Api.Controllers
{
    /// <summary>
    /// 羊只生产控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ShiftsController : ControllerBase
    {
        private readonly IMediator mediator;

        /// <summary>
        /// 构造方式注入
        /// </summary>
        /// <param name="mediator"></param>
        public ShiftsController(IMediator mediator)
        {
            this.mediator = mediator;
        }



        /// <summary>
        /// 添加羊只转舍信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> ShiftCreate(ShiftCreateCommand command)
        {
            return Ok(await mediator.Send(command));
        }

        /// <summary>
        /// 删除转舍信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<IActionResult> ShiftDelete([FromQuery] ShiftDeleteCommand command)
        {
            return Ok(await mediator.Send(command));
        }

        /// <summary>
        /// 修改转舍信息
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        public async Task<IActionResult> ShiftUpdate(ShiftUpdateCommand command)
        {
            return Ok(await mediator.Send(command));
        }
    }
}
